define(['egis'], function (egis) {
    Window.deserializer = Window.deserializer || new egis.core.Deserializer();
    Window.container = Window.container || {};
    dsBridge.register('create_TileLayer', function (sourceId, name, clientId, clientSecret, zIndex) {
        //var resthttp = Window.container[restHttpId];
        var layer = new egis.carto.TileLayer({
            "name": name,
            "zIndex": zIndex,
            //"restHttp": resthttp,
            "clientId": clientId,
            "clientSecret": clientSecret
        });
        Window.container[sourceId] = layer;
    })

    dsBridge.register('TileLayer_setSource', function (sourceId, source) {
        var layer = Window.container[sourceId];
        source = JSON.parse(source);
        source.getSourceType = function () {
            return source.sourceType;
        }
        /*source['tileLoadFunction'] = function (imageTile, src) {
            var image = imageTile.getImage();
            var tileCoord = imageTile.getTileCoord();
            var z = tileCoord[0], x = tileCoord[1], y = -tileCoord[2]-1;
            image.src = src;
        }*/
        layer.setSource(source);
    })

    /*dsBridge.register('TileLayer_getZIndex', function (sourceId) {
        var source = Window.container[sourceId];
        return source.getZIndex();
    })

    dsBridge.register('TileLayer_setZIndex', function (sourceId, zIndex) {
        var source = Window.container[sourceId];
        source.setZIndex(zIndex);
    })

    dsBridge.register('TileLayer_setVisible', function (sourceId, visible) {
        var source = Window.container[sourceId];
        source.setVisible(visible);
    })

    dsBridge.register('TileLayer_setOpacity', function (sourceId, opacity) {
        var source = Window.container[sourceId];
        source.setOpacity(opacity);
    })

    dsBridge.register('TileLayer_setMinZoom', function (sourceId, minZoom) {
        var source = Window.container[sourceId];
        source.setMinZoom(minZoom);
    })

    dsBridge.register('TileLayer_setMaxZoom', function (sourceId, maxZoom) {
        var source = Window.container[sourceId];
        source.setMaxZoom(maxZoom);
    })*/
})